class CategoryPageController < ApplicationController

  

    def subcat_view

      @categories = Category.find_by_stripped_name(params[:id])
       id = @categories.sub_categories
       @university = University.find_by_stripped_name(params[:university])
       @add = @categories.advertisments.paginate(:page =>params[:page],:per_page => 10,:conditions =>{:sub_category_id => id , :university_id => @university.id})

    end

    def insert_ads
      @advertisments = Advertisment.find(:all,:limit => 10)
      @tags = Tag.find(:all)


          @tagcloud = Hash.new
            @tags.each do |t|
              @result=t.name.split(",")
                @result.each do |tags|
                  @tagcloud[tags]
                    if(@tagcloud[tags].nil?)
                        @tagcloud[tags]=1
                    else
                        @tagcloud[tags]=@tagcloud[tags]+1
                    end
                end
                
           end


      
      @maxsize = 40;
      @minsize = 10;
      @maxval = @tagcloud.values.max
      @minval = @tagcloud.values.min
      @spread = @maxval - @minval;
      @step = ((@maxsize - @minsize)*15) / (@spread);


      
    end
def invite_friends
#@user = User.find(params[:id])
end

def import
#@users = User.find(params[:id])
begin
@sites = {"gmail"  => Contacts::Gmail, "yahoo" => Contacts::Yahoo, "hotmail" => Contacts::Hotmail}
@contacts = @sites[params[:from]].new(params[:login], params[:password]).contacts
#@users , @no_users = [], []
#@contacts.each do |contact|
#if u = User.find(:first , :conditions => @users.email = ‘#{contact[1]}’ , :include =>[:user])
#if u = User.find(:first , :conditions => "email = '#{contact[1]}'" )
#@users << u
#else
#@no_users << {:name => contact[0] , :email => contact[1]}
#end
#end
respond_to do |format|
format.html {render :template => 'shared/_contact_list', :layout => false}
format.xml {render :xml => @contacts.to_xml}
end
end
    
end

end

